﻿
namespace ST.Common.Util.Mvc
{
	public interface IBaseService<TKey, TModel>
	{
		/// <summary>
		/// 新增信息
		/// </summary>
		/// <param name="model"></param>
		/// <returns></returns>
		TKey Add(TModel model);

		/// <summary>
		/// 修改信息
		/// </summary>
		/// <param name="model"></param>
		/// <returns></returns>
		bool Update(TModel model);

		/// <summary>
		/// 按主键删除信息
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		bool Delete(TKey id);

		/// <summary>
		/// 删除信息
		/// </summary>
		/// <param name="model"></param>
		/// <returns></returns>
		bool Delete(TModel model);

		/// <summary>
		/// 按主键是否存在
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		bool Exists(TKey id);

		/// <summary>
		/// 是否存在
		/// </summary>
		/// <param name="model"></param>
		/// <returns></returns>
		bool Exists(TModel model);

		/// <summary>
		/// 按主键获取信息
		/// </summary>
		/// <param name="id"></param>
		/// <exception cref="System.ArgumentException"></exception>
		/// <returns></returns>
		TModel Get(TKey id, bool deattached = false);

		/// <summary>
		/// 获取分页数据
		/// </summary>
		/// <param name="pageNum">页码（从1开始）</param>
		/// <param name="pageSize">每页显示数量</param>
		/// <param name="sortOrder">排序（格式:{字段}_{asc|desc}）</param>
		/// <returns></returns>
		PageData GetPageList(int pageNum, int pageSize, string sortOrder);
	}
}